package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.AnswerComment;
import cn.wolfcode.trip.base.mapper.AnswerCommentMapper;
import cn.wolfcode.trip.base.query.AnswerCommentQuery;
import cn.wolfcode.trip.base.service.IAnswerCommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnswerCommentServiceImpl implements IAnswerCommentService {
    @Autowired
    private AnswerCommentMapper answerCommentMapper;

    @Override
    public PageInfo selectForList(AnswerCommentQuery qo,Long answerId) {
        qo.setOrderBy("ac.commentTime DESC");
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<AnswerComment> list = answerCommentMapper.selectForList(qo,answerId);
        return new PageInfo(list);
    }


    @Override
    public List<AnswerComment> listAll() {
        return answerCommentMapper.selectAll();
    }

    @Override
    public AnswerComment get(Long id) {
        return answerCommentMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveCommentByanswerId(AnswerComment answerComment, Long answerId) {
       answerCommentMapper.insert(answerComment,answerId);
    }


}
